
<script type="text/javascript">
	
	$(document).ready(function() {
	    
		// CRUD
		add_data = function (){
			$('#dialog').dialog({
				title: 'Tambah Data Transaksi',
				width: 500,
				height: 350,
				closed: true,
				cache: false,
				href: base_url+'transaksi_keuangan/add',
				modal: true
			});
			 
			$('#dialog').dialog('open');
			url = base_url+'transaksi_keuangan/save';
		}

		saveData = function(){
			$('#form1').form('submit',{
				url: url,
				onSubmit: function(){
					return $(this).form('validate');
				},
				success: function(result){
					//alert(result);
					var result = eval('('+result+')');
					if (result.success){
						$('#dialog').dialog('close');		// close the dialog
						$('#dg').datagrid('reload');
					} else {
						$.messager.show({
							title: 'Error',
							msg: result.msg
						});
					}
				}
			});
			
		}

		// load grid
		$(function(){
			$('#dg').datagrid({url:"<?=base_url()?>transaksi_keuangan/grid"});
		});	

	});

</script>

<table id="dg" title="" data-options="
			rownumbers:true,
			singleSelect:true,
			autoRowHeight:false,
			pagination:true,
			pageSize:30,
			fit:true,
			toolbar:'#toolbar',
			">
	<thead>
		<tr>
			<th field="tgl_posting" sortable="true" width="90">Tgl Posting</th>
			<th field="tgl_transaksi" sortable="true" width="90">Tgl Transaksi</th>
			<th field="akun" sortable="true" width="150">Kode Akun</th>
			<th field="debit" sortable="true" width="75">Debit</th>
			<th field="kredit" sortable="true" width="75">Kredit</th>
			<th field="saldo" sortable="true" width="90">Saldo</th>
			<th field="deskripsi" sortable="true" width="200">Keterangan</th>
		</tr>
	</thead>
</table>

<div id="toolbar" style="padding:5px;height:auto">
	<table>
		<tr>
			<td><a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="add_data()">Tambah Transaksi</a></td>
		</tr>
	</table>
</div>